#include <iostream>
#include <vector>
using namespace std;

class Solution
{
public:
	vector<vector<int>> construct2DArray(vector<int>& original, int m, int n)
	{
		vector<vector<int>> v;
		if (original.size() != (m * n))
		{
			return v;
		}
		vector<int> tmp;
		
		for (int i = 0; i < original.size(); i++)
		{
			tmp.emplace_back(original[i]);
			if ((i + 1) % n == 0)
			{
				v.emplace_back(tmp);
				tmp.clear();
			}
		}

		return v;
	}
};

int main()
{
	vector<int> original = { 1, 2, 3};
	int m = 1, n = 3;

	Solution xz;
	vector<vector<int>> v = xz.construct2DArray(original, m, n);

	for (auto row : v)
	{
		for (auto elem : row)
		{
			cout << elem << " ";
		}
		cout << "\n";
	}

	return 0;
}
